﻿'Written By Sean Molenaar
'0.1.0 Alpha tests only Butane
'0.2.0 integrating my old quiz into the form
'0.2.5 finaly got it to work
'0.3.0 all the alkane work
'0.3.2 got alkenen as wel now
'0.9.5 got options as wel as a main menu now
'1.0.0 everithing's coded and up for first alpha
'1.1.0 making a auto save if a subform exits
'1.1.3 added a splash screen


Public Class frmMenu
    Private goodI As String
    Private goodII As String
    Private b As String() = System.IO.File.ReadAllLines("highscore.txt")


    Public Sub DeleteLine(ByRef FileAddress As String, ByRef line As Integer)
        Dim TheFileLines As New List(Of String)
        TheFileLines.AddRange(System.IO.File.ReadAllLines(FileAddress))
        ' if line is beyond end of list the exit sub
        If line >= TheFileLines.Count Then Exit Sub
        TheFileLines.RemoveAt(line)
        System.IO.File.WriteAllLines(FileAddress, TheFileLines.ToArray)
    End Sub

    Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbScore.Click
        goodI = b(0)
        goodII = goodI + " punten"
        txtScore.Text = goodII
    End Sub
    Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbExit.Click
        goodI = b(0)
        DeleteLine("highscore.txt", 0)
        DeleteLine("wrong.txt", 0)
        DeleteLine("good.txt", 0)
        Using sw As New IO.StreamWriter("highscore.txt")
            sw.WriteLine(goodI)
        End Using
        Using sw As New IO.StreamWriter("wrong.txt")
            sw.WriteLine(0)
        End Using
        Using sw As New IO.StreamWriter("good.txt")
            sw.WriteLine(0)
        End Using
        End
    End Sub


    Private Sub cmbStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbStart.Click
        If optAlkane.Checked = True Then
            frmAlkane.Show()
        End If
        If optAlkene.Checked = True Then
            frmAlkene.Show()
        End If
        If optCycloalkane.Checked = True Then
            frmCycloalkane.Show()
        End If
        If optCycloalkene.Checked = True Then
            frmCycloalkene.Show()
        End If
        If optAlkyle.Checked = True Then
            frmAlkyle.Show()
        End If
        If optCarbonacid.Checked = True Then
            frmCarbonacid.Show()
        End If
        If optMixed.Checked = True Then
            frmMixed.Show()
        End If
        If optHalogen.Checked = True Then
            frmHalogen.Show()
        End If
        If optCandh.Checked = True Then
            frmCandh.Show()
        End If
    End Sub

    Private Sub cmbAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbAbout.Click
        frmAbout.Show()
    End Sub
End Class